<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admmaskgest.php,v $ 
 * $Date: 2005/10/21 12:58:07 $ 
 * $Revision: 1.3 $ 
 * 
 * ********* CVS HEADER ********* 
 */
require_once("module/TPLN/TPLN.php"); 
$TPLN = new TPLN; 
$TPLN->Open($op_basepath."tpl/admmaskgest.html"); 
$TPLN->IncludeFile("header","environnement/$session[environnement]/header.php"); 
$TPLN->IncludeFile("footer","environnement/$session[environnement]/footer.php");

require_once(get_path_module("admin"));
$pc = new panneau_controle();
$pc->calculRubriqueParFonction($op);
$TPLN->Parse("panneau_controle",$pc->retourneEntete());


/*$query="SELECT groupe.id AS id_groupe, groupe.nom AS nom FROM groupe WHERE groupe.id='$argid'";
$result=rportalrequete($query) or die ("ERREUR 0032");
$row=rportalligne($result);
$TPLN->Parse("nom_groupe",$row['nom']); 

$TPLN->Parse("argid",$argid);
*/


$query="SELECT masque.id_mask AS id_mask, masque.nom_mask AS nom_mask FROM masque ORDER BY nom_mask";
$result=rportalrequete($query) or rportalerreur($query,"?op=");

if(rportalnbresult($result)==0){        
    $TPLN->EraseBloc("bloc1");
}else{	
	while($row=rportalligne($result)){
        $TPLN->Parse("bloc1.nom_masque",$row['nom_mask']);
  
  		$id=$row['id_mask'];
  		      
        $query2="SELECT DISTINCT droitmasque.nom_droit AS nom_droit, droitmasque.id_mask  from droitmasque WHERE droitmasque.id_mask='$id'";
        $result2=rportalrequete($query2) or rportalerreur($query2,"?op=");
        if(rportalnbresult($result2)==0){        
    		$TPLN->EraseBloc("bloc1.bloc2");
		}else{
			
        	while($row2=rportalligne($result2)){  
        		$TPLN->Parse("bloc1.bloc2.id_mask",$id);      	
        		$TPLN->Parse("bloc1.bloc2.nom_droit",$row2['nom_droit']);        		             
        		$TPLN->Loop("bloc1.bloc2");
        	}
        }
        
        $TPLN->Parse("bloc1.id_mask",$id);
        
		//class...
        $TPLN->Loop("bloc1");
    }
}

$query = "SELECT * FROM droitmasquenom ORDER BY id";
$result=rportalrequete($query) or rportalerreur($query,"?op=");
if(rportalnbresult($result)==0){        
    $TPLN->EraseBloc("droit");
}else{	
	$class="liste_impaire"; 
	while($row=rportalligne($result)){
		$TPLN->Parse("droit.nom",$row['nom']);
		$TPLN->Parse("droit.description",$row['description']);
		$TPLN->Parse("droit.id",$row['id']);
		$TPLN->Parse("droit.classe",$class);
        if($class!="liste_impaire") 
        { 
            $class="liste_impaire"; 
        }else{ 
            $class="liste_paire"; 
        } 
        $TPLN->Loop("droit");
	}
}
$TPLN->Write();
?>